using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Admin_ThemSeminar : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HuongNghienCuuBUS hncBus = new HuongNghienCuuBUS();
            lbHNC.DataSource = hncBus.LayMang_HuongNC();
            lbHNC.DataTextField = "HuongNC";
            lbHNC.DataValueField = "MaHuongNC";
            lbHNC.DataBind();
            lbHNC.SelectedIndex = 0;
            GiaoVienBUS gvBus = new GiaoVienBUS();
            lbNguoiTB.DataSource = gvBus.LayMang_GiaoVien();
            lbNguoiTB.DataTextField = "TenGiaoVien";
            lbNguoiTB.DataValueField = "MaGiaoVien";
            lbNguoiTB.DataBind();
            lbNguoiTB.SelectedIndex = 0;
        }
    }
    protected void btnThem_Click(object sender, EventArgs e)
    {
        imgLoading.Visible = true;
        if (txtNoiDungTB.Text.Length == 0)
            imgNoiDung.Visible = true;
        else
            imgNoiDung.Visible = false;
        if (txtVanDeTB.Text.Length == 0)
            imgVanDe.Visible = true;
        else
            imgVanDe.Visible = false;
        if (ngaySeminar.Text.Length == 0)
            imgNgayTrinhBay.Visible = true;
        else
            imgNgayTrinhBay.Visible = false;
        
        if (!imgNgayTrinhBay.Visible && !imgNoiDung.Visible && !imgVanDe.Visible)
        {
            SeminarBUS sBus = new SeminarBUS();
            SeminarDTO sDto = new SeminarDTO();
            sDto.VanDeTB = txtVanDeTB.Text;
            sDto.TomTatNoiDung = txtNoiDungTB.Text;
            sDto.NgaySeminar = DateTime.Parse(ngaySeminar.Text);
            sDto.NhanXet = "";
            sDto.TaiLieuDinhKem = "";
            sDto.MaHuongNC = int.Parse(lbHNC.SelectedItem.Value.ToString());
            sDto.MaNguoiTrinhBay = lbNguoiTB.SelectedItem.Value.ToString();
            sBus.insert(sDto);
        }
        imgLoading.Visible = false;
    }
    protected void txtVanDeTB_TextChanged(object sender, EventArgs e)
    {
        txtVanDeTB.Text = "";
    }
    protected void lbNguoiTB_SelectedIndexChanged(object sender, EventArgs e)
    {
       // btnThem.Text = lbNguoiTB.SelectedItem.Value.ToString();
    }
}
